package com.hnust.controller;

import com.hnust.service.ModifyScoreService;
import com.hnust.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ModifyScoreController {
    @Autowired
    private ModifyScoreService modifyScoreService;


    // 修改分数
    @PostMapping("/modifyScore")
    public Result<Object> modifyScore(@RequestParam("studentId") String studentId,@RequestParam("testId") String testId,@RequestParam("queTypeNum") int queTypeNum,@RequestParam("queNum") int queNum,@RequestParam("score") double score){
        List<Double> scoreList = modifyScoreService.modifyScore(studentId,testId,queTypeNum,queNum,score);
//        System.out.println("scoreList是否为空"+scoreList.isEmpty());
        System.out.println(scoreList);
        try {
            if(scoreList.isEmpty()){
                System.out.println("scoreList是否为空"+scoreList.isEmpty());
                return new Result<Object>(0,"修改失败",null);
            }else{
                System.out.println("scoreList是否为空"+scoreList.isEmpty());
                return new Result<Object>(200,"修改成功",scoreList);
            }
        }catch (Exception e){
            System.out.println("错误");
            return new Result<Object>(0,"操作异常，请稍后再试",null);
        }
    }
}
